﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.SqlClient;
using System.Web;
using SD.Commons.Helpers;

namespace MockPrjTeam1.DAO
{
    public class ChangePassDAO
    {

        public bool UpdateUser(string UserName, string Email, string NewPassword)
        {
            //LoginLinqDataContext db = new LoginLinqDataContext();
            //IEnumerable<User> users = from p in db.Users
            //                          where p.Account == UserName
            //                          select p;
            //foreach (User user in users)
            //{
            //    if (Email == user.Email)
            //    {
            //        user.Password = NewPassword;
            //        db.SubmitChanges();
            //        return true;
            //    }
            //}
            //return false;

            var temp = new Collection<SqlParameter>();
            temp.Add(new SqlParameter("p1", UserName));
            temp.Add(new SqlParameter("p2", Email));
            temp.Add(new SqlParameter("p3", NewPassword));

            var result = SqlHelper.ExecuteNonQuery("ChangePass", temp);
            if (result != 0)
            { 
                return true; 
            }
            else return false;
        }

    }
}